﻿using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

using Unity.String.Text.Charset;

namespace Unity.String
{
    #pragma warning disable S1199
    #pragma warning disable S3626
    public static class UnityString
    {
        static Encoding defaultEncoding = new UTF8Encoding(false);

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        internal static void AppendChars<TBufferWriter>(ref TBufferWriter stringBuilder, ReadOnlySpan<char> chars)
            where TBufferWriter : IBufferWriter<byte>
        {
            var span = stringBuilder.GetSpan(defaultEncoding.GetMaxByteCount(chars.Length));
            stringBuilder.Advance(defaultEncoding.GetBytes(chars, span));
        }

        /// <summary>Create the Utf16 string StringBuilder.</summary>
        public static Utf16ValueStringBuilder CreateStringBuilder()
        {
            return new Utf16ValueStringBuilder(false);
        }

        /// <summary>Create the Utf16 string StringBuilder, when true uses thread-static buffer that is faster but must return immediately.</summary>
        public static Utf8ValueStringBuilder CreateUtf8StringBuilder()
        {
            return new Utf8ValueStringBuilder(false);
        }

        /// <summary>Create the Utf8(`Span[byte]`) StringBuilder.</summary>
        /// <param name="notNested">
        /// If true uses thread-static buffer that is faster but must return immediately.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// This exception is thrown when <c>new StringBuilder(disposeImmediately: true)</c> or <c>ZString.CreateUtf8StringBuilder(notNested: true)</c> is nested.
        /// See the README.md
        /// </exception>
        public static Utf16ValueStringBuilder CreateStringBuilder(bool notNested)
        {
            return new Utf16ValueStringBuilder(notNested);
        }

        /// <summary>Create the Utf8(`Span[byte]`) StringBuilder, when true uses thread-static buffer that is faster but must return immediately.</summary>
        /// <param name="notNested">
        /// If true uses thread-static buffer that is faster but must return immediately.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// This exception is thrown when <c>new StringBuilder(disposeImmediately: true)</c> or <c>ZString.CreateUtf8StringBuilder(notNested: true)</c> is nested.
        /// See the README.md
        /// </exception>
        public static Utf8ValueStringBuilder CreateUtf8StringBuilder(bool notNested)
        {
            return new Utf8ValueStringBuilder(notNested);
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(char separator, params T[] values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal<T>(separatorValue, values.AsSpan());
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(char separator, List<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, (IReadOnlyList<T>)values);
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(char separator, ReadOnlySpan<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values);
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(char separator, IEnumerable<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values);
        }

        public static string Join<T>(char separator, ICollection<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values.AsEnumerable());
        }

        public static string Join<T>(char separator, IList<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values);
        }

        public static string Join<T>(char separator, IReadOnlyList<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values);
        }

        public static string Join<T>(char separator, IReadOnlyCollection<T> values)
        {
            ReadOnlySpan<char> separatorValue = stackalloc char[1] { separator };
            return JoinInternal(separatorValue, values.AsEnumerable());
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(string separator, params T[] values)
        {
            return JoinInternal<T>(separator.AsSpan(), values.AsSpan());
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(string separator, List<T> values)
        {
            return JoinInternal(separator.AsSpan(), (IReadOnlyList<T>)values);
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(string separator, ReadOnlySpan<T> values)
        {
            return JoinInternal(separator.AsSpan(), values);
        }

        public static string Join<T>(string separator, ICollection<T> values)
        {
            return JoinInternal(separator.AsSpan(), values.AsEnumerable());
        }

        public static string Join<T>(string separator, IList<T> values)
        {
            return JoinInternal(separator.AsSpan(), values);
        }

        public static string Join<T>(string separator, IReadOnlyList<T> values)
        {
            return JoinInternal(separator.AsSpan(), values);
        }

        public static string Join<T>(string separator, IReadOnlyCollection<T> values)
        {
            return JoinInternal(separator.AsSpan(), values.AsEnumerable());
        }

        /// <summary>Concatenates the elements of an array, using the specified seperator between each element.</summary>
        public static string Join<T>(string separator, IEnumerable<T> values)
        {
            return JoinInternal(separator.AsSpan(), values);
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(params T[] values)
        {
            return JoinInternal<T>(default, values.AsSpan());
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(List<T> values)
        {
            return JoinInternal(default, (IReadOnlyList<T>)values);
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(ReadOnlySpan<T> values)
        {
            return JoinInternal(default, values);
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(ICollection<T> values)
        {
            return JoinInternal(default, values.AsEnumerable());
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(IList<T> values)
        {
            return JoinInternal(default, values);
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(IReadOnlyList<T> values)
        {
            return JoinInternal(default, values);
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(IReadOnlyCollection<T> values)
        {
            return JoinInternal(default, values.AsEnumerable());
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T>(IEnumerable<T> values)
        {
            return JoinInternal(default, values);
        }

        static string JoinInternal<T>(ReadOnlySpan<char> separator, IList<T> values)
        {
            var readOnlyList = values as IReadOnlyList<T>;
            // Boxing will occur, but JIT will be de-virtualized.
            readOnlyList = readOnlyList ?? new ReadOnlyListAdaptor<T>(values);
            return JoinInternal(separator, readOnlyList);
        }

        static string JoinInternal<T>(ReadOnlySpan<char> separator, IReadOnlyList<T> values)
        {
            var count = values.Count;
            if (count == 0)
            {
                return string.Empty;
            }
            else if (typeof(T) == typeof(string) && count == 1)
            {
                return Unsafe.As<string>(values[0]);
            }

            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendJoinInternal(separator, values);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        static string JoinInternal<T>(ReadOnlySpan<char> separator, ReadOnlySpan<T> values)
        {
            if (values.Length == 0)
            {
                return string.Empty;
            }
            else if (typeof(T) == typeof(string) && values.Length == 1)
            {
                return Unsafe.As<string>(values[0]);
            }

            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendJoinInternal(separator, values);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        static string JoinInternal<T>(ReadOnlySpan<char> separator, IEnumerable<T> values)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendJoinInternal(separator, values);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1>(string format, T1 arg1)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1>(ReadOnlySpan<char> format, T1 arg1)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2>(string format, T1 arg1, T2 arg2)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2>(ReadOnlySpan<char> format, T1 arg1, T2 arg2)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3>(string format, T1 arg1, T2 arg2, T3 arg3)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified objects.</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                stringBuilder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1> PrepareUtf16<T1>(string format)
        {
            return new Utf16PreparedFormat<T1>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1> PrepareUtf8<T1>(string format)
        {
            return new Utf8PreparedFormat<T1>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2> PrepareUtf16<T1, T2>(string format)
        {
            return new Utf16PreparedFormat<T1, T2>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2> PrepareUtf8<T1, T2>(string format)
        {
            return new Utf8PreparedFormat<T1, T2>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3> PrepareUtf16<T1, T2, T3>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3> PrepareUtf8<T1, T2, T3>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4> PrepareUtf16<T1, T2, T3, T4>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4> PrepareUtf8<T1, T2, T3, T4>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5> PrepareUtf16<T1, T2, T3, T4, T5>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5> PrepareUtf8<T1, T2, T3, T4, T5>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6> PrepareUtf16<T1, T2, T3, T4, T5, T6>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6> PrepareUtf8<T1, T2, T3, T4, T5, T6>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> PrepareUtf16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(string format)
        {
            return new Utf16PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(format);
        }

        /// <summary>Prepare string format to avoid parse template in each operation.</summary>
        public static Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> PrepareUtf8<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(string format)
        {
            return new Utf8PreparedFormat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(format);
        }

        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1>(IBufferWriter<byte> bufferWriter, string format, T1 arg1)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        case 11:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg12, indexParse.Alignment, writeFormat, nameof(arg12));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        case 11:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg12, indexParse.Alignment, writeFormat, nameof(arg12));
                            continue;
                        case 12:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg13, indexParse.Alignment, writeFormat, nameof(arg13));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        case 11:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg12, indexParse.Alignment, writeFormat, nameof(arg12));
                            continue;
                        case 12:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg13, indexParse.Alignment, writeFormat, nameof(arg13));
                            continue;
                        case 13:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg14, indexParse.Alignment, writeFormat, nameof(arg14));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        case 11:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg12, indexParse.Alignment, writeFormat, nameof(arg12));
                            continue;
                        case 12:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg13, indexParse.Alignment, writeFormat, nameof(arg13));
                            continue;
                        case 13:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg14, indexParse.Alignment, writeFormat, nameof(arg14));
                            continue;
                        case 14:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg15, indexParse.Alignment, writeFormat, nameof(arg15));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }
        /// <summary>Replaces one or more format items in a string with the string representation of some specified values.</summary>
        public static void Utf8Format<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(IBufferWriter<byte> bufferWriter, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var copyFrom = 0;
            for (int i = 0; i < format.Length; i++)
            {
                var c = format[i];
                if (c == '{')
                {
                    // escape.
                    if (i == format.Length - 1)
                    {
                        throw new FormatException("invalid format");
                    }

                    if (i != format.Length && format[i + 1] == '{')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '{'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                    }

                    // try to find range
                    var indexParse = FormatParser.Parse(format, i);
                    copyFrom = indexParse.LastIndex;
                    i = indexParse.LastIndex - 1;
                    var writeFormat = StandardFormat.Parse(indexParse.FormatString);
                    switch (indexParse.Index)
                    {
                        case 0:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg1, indexParse.Alignment, writeFormat, nameof(arg1));
                            continue;
                        case 1:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg2, indexParse.Alignment, writeFormat, nameof(arg2));
                            continue;
                        case 2:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg3, indexParse.Alignment, writeFormat, nameof(arg3));
                            continue;
                        case 3:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg4, indexParse.Alignment, writeFormat, nameof(arg4));
                            continue;
                        case 4:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg5, indexParse.Alignment, writeFormat, nameof(arg5));
                            continue;
                        case 5:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg6, indexParse.Alignment, writeFormat, nameof(arg6));
                            continue;
                        case 6:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg7, indexParse.Alignment, writeFormat, nameof(arg7));
                            continue;
                        case 7:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg8, indexParse.Alignment, writeFormat, nameof(arg8));
                            continue;
                        case 8:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg9, indexParse.Alignment, writeFormat, nameof(arg9));
                            continue;
                        case 9:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg10, indexParse.Alignment, writeFormat, nameof(arg10));
                            continue;
                        case 10:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg11, indexParse.Alignment, writeFormat, nameof(arg11));
                            continue;
                        case 11:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg12, indexParse.Alignment, writeFormat, nameof(arg12));
                            continue;
                        case 12:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg13, indexParse.Alignment, writeFormat, nameof(arg13));
                            continue;
                        case 13:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg14, indexParse.Alignment, writeFormat, nameof(arg14));
                            continue;
                        case 14:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg15, indexParse.Alignment, writeFormat, nameof(arg15));
                            continue;
                        case 15:
                            Utf8FormatHelper.FormatTo(ref bufferWriter, arg16, indexParse.Alignment, writeFormat, nameof(arg16));
                            continue;
                        default:
                            StringFormatterException.ThrowFormatException();
                            break;
                    }

                    StringFormatterException.ThrowFormatException();
                }
                else if (c == '}')
                {
                    if (i + 1 < format.Length && format[i + 1] == '}')
                    {
                        var size = i - copyFrom;
                        var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(size));
                        var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, size), buffer);
                        bufferWriter.Advance(written);
                        i = i + 1; // skip escaped '}'
                        copyFrom = i;
                        continue;
                    }
                    else
                    {
                        StringFormatterException.ThrowFormatException();
                    }
                }
            }

            {
                // copy final string
                var copyLength = format.Length - copyFrom;
                if (copyLength > 0)
                {
                    var buffer = bufferWriter.GetSpan(defaultEncoding.GetMaxByteCount(copyLength));
                    var written = defaultEncoding.GetBytes(format.AsSpan(copyFrom, copyLength), buffer);
                    bufferWriter.Advance(written);
                }
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1>(T1 arg1)
        {
            if (typeof(T1) == typeof(string))
            {
                return (arg1 != null) ? Unsafe.As<string>(arg1) : string.Empty;
            }

            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2>(T1 arg1, T2 arg2)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                if (typeof(T12) == typeof(string))
                {
                    if (arg12 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T12, string>(ref arg12));
                    }
                }
                else if (typeof(T12) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T12, int>(ref arg12));
                }
                else
                {
                    stringBuilder.Append(arg12);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                if (typeof(T12) == typeof(string))
                {
                    if (arg12 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T12, string>(ref arg12));
                    }
                }
                else if (typeof(T12) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T12, int>(ref arg12));
                }
                else
                {
                    stringBuilder.Append(arg12);
                }

                if (typeof(T13) == typeof(string))
                {
                    if (arg13 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T13, string>(ref arg13));
                    }
                }
                else if (typeof(T13) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T13, int>(ref arg13));
                }
                else
                {
                    stringBuilder.Append(arg13);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                if (typeof(T12) == typeof(string))
                {
                    if (arg12 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T12, string>(ref arg12));
                    }
                }
                else if (typeof(T12) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T12, int>(ref arg12));
                }
                else
                {
                    stringBuilder.Append(arg12);
                }

                if (typeof(T13) == typeof(string))
                {
                    if (arg13 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T13, string>(ref arg13));
                    }
                }
                else if (typeof(T13) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T13, int>(ref arg13));
                }
                else
                {
                    stringBuilder.Append(arg13);
                }

                if (typeof(T14) == typeof(string))
                {
                    if (arg14 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T14, string>(ref arg14));
                    }
                }
                else if (typeof(T14) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T14, int>(ref arg14));
                }
                else
                {
                    stringBuilder.Append(arg14);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                if (typeof(T12) == typeof(string))
                {
                    if (arg12 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T12, string>(ref arg12));
                    }
                }
                else if (typeof(T12) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T12, int>(ref arg12));
                }
                else
                {
                    stringBuilder.Append(arg12);
                }

                if (typeof(T13) == typeof(string))
                {
                    if (arg13 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T13, string>(ref arg13));
                    }
                }
                else if (typeof(T13) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T13, int>(ref arg13));
                }
                else
                {
                    stringBuilder.Append(arg13);
                }

                if (typeof(T14) == typeof(string))
                {
                    if (arg14 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T14, string>(ref arg14));
                    }
                }
                else if (typeof(T14) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T14, int>(ref arg14));
                }
                else
                {
                    stringBuilder.Append(arg14);
                }

                if (typeof(T15) == typeof(string))
                {
                    if (arg15 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T15, string>(ref arg15));
                    }
                }
                else if (typeof(T15) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T15, int>(ref arg15));
                }
                else
                {
                    stringBuilder.Append(arg15);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }

        /// <summary>Concatenates the string representation of some specified objects.</summary>
        public static string Concat<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
        {
            var stringBuilder = new Utf16ValueStringBuilder(true);
            try
            {
                if (typeof(T1) == typeof(string))
                {
                    if (arg1 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T1, string>(ref arg1));
                    }
                }
                else if (typeof(T1) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T1, int>(ref arg1));
                }
                else
                {
                    stringBuilder.Append(arg1);
                }

                if (typeof(T2) == typeof(string))
                {
                    if (arg2 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T2, string>(ref arg2));
                    }
                }
                else if (typeof(T2) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T2, int>(ref arg2));
                }
                else
                {
                    stringBuilder.Append(arg2);
                }

                if (typeof(T3) == typeof(string))
                {
                    if (arg3 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T3, string>(ref arg3));
                    }
                }
                else if (typeof(T3) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T3, int>(ref arg3));
                }
                else
                {
                    stringBuilder.Append(arg3);
                }

                if (typeof(T4) == typeof(string))
                {
                    if (arg4 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T4, string>(ref arg4));
                    }
                }
                else if (typeof(T4) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T4, int>(ref arg4));
                }
                else
                {
                    stringBuilder.Append(arg4);
                }

                if (typeof(T5) == typeof(string))
                {
                    if (arg5 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T5, string>(ref arg5));
                    }
                }
                else if (typeof(T5) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T5, int>(ref arg5));
                }
                else
                {
                    stringBuilder.Append(arg5);
                }

                if (typeof(T6) == typeof(string))
                {
                    if (arg6 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T6, string>(ref arg6));
                    }
                }
                else if (typeof(T6) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T6, int>(ref arg6));
                }
                else
                {
                    stringBuilder.Append(arg6);
                }

                if (typeof(T7) == typeof(string))
                {
                    if (arg7 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T7, string>(ref arg7));
                    }
                }
                else if (typeof(T7) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T7, int>(ref arg7));
                }
                else
                {
                    stringBuilder.Append(arg7);
                }

                if (typeof(T8) == typeof(string))
                {
                    if (arg8 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T8, string>(ref arg8));
                    }
                }
                else if (typeof(T8) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T8, int>(ref arg8));
                }
                else
                {
                    stringBuilder.Append(arg8);
                }

                if (typeof(T9) == typeof(string))
                {
                    if (arg9 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T9, string>(ref arg9));
                    }
                }
                else if (typeof(T9) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T9, int>(ref arg9));
                }
                else
                {
                    stringBuilder.Append(arg9);
                }

                if (typeof(T10) == typeof(string))
                {
                    if (arg10 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T10, string>(ref arg10));
                    }
                }
                else if (typeof(T10) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T10, int>(ref arg10));
                }
                else
                {
                    stringBuilder.Append(arg10);
                }

                if (typeof(T11) == typeof(string))
                {
                    if (arg11 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T11, string>(ref arg11));
                    }
                }
                else if (typeof(T11) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T11, int>(ref arg11));
                }
                else
                {
                    stringBuilder.Append(arg11);
                }

                if (typeof(T12) == typeof(string))
                {
                    if (arg12 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T12, string>(ref arg12));
                    }
                }
                else if (typeof(T12) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T12, int>(ref arg12));
                }
                else
                {
                    stringBuilder.Append(arg12);
                }

                if (typeof(T13) == typeof(string))
                {
                    if (arg13 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T13, string>(ref arg13));
                    }
                }
                else if (typeof(T13) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T13, int>(ref arg13));
                }
                else
                {
                    stringBuilder.Append(arg13);
                }

                if (typeof(T14) == typeof(string))
                {
                    if (arg14 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T14, string>(ref arg14));
                    }
                }
                else if (typeof(T14) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T14, int>(ref arg14));
                }
                else
                {
                    stringBuilder.Append(arg14);
                }

                if (typeof(T15) == typeof(string))
                {
                    if (arg15 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T15, string>(ref arg15));
                    }
                }
                else if (typeof(T15) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T15, int>(ref arg15));
                }
                else
                {
                    stringBuilder.Append(arg15);
                }

                if (typeof(T16) == typeof(string))
                {
                    if (arg16 != null)
                    {
                        stringBuilder.Append(Unsafe.As<T16, string>(ref arg16));
                    }
                }
                else if (typeof(T16) == typeof(int))
                {
                    stringBuilder.Append(Unsafe.As<T16, int>(ref arg16));
                }
                else
                {
                    stringBuilder.Append(arg16);
                }

                return stringBuilder.ToString();
            }
            finally
            {
                stringBuilder.Dispose();
            }
        }
    }
    #pragma warning restore S3626
    #pragma warning restore S1199
}
